﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//该类存储的是有关用户信息、Cookie、页面权限、按钮权限的有关方法
//以及系统常用的常量
namespace StorageManage
{
    public class OperateContext
    {
        public const string CookiePath = "/admin/";
        public const string InfoKey = "ainfo";
        public const string PermissionKey = "apermission";
        public const string BtnPermissionKey = "btnpermission";
        public const string AuthInfoKey = "authinfo";
        public const string IsAuth = "IsAuth";
        public const string theme = "theme";
        public const string WaitDeal = "waitDeal";
        private const string page = "page";
        private const string rows = "rows";
        private const string sort = "sort";
        private const string order = "order";
        private const string comboTotal = "comboTotal";
        private const string comboDetail = "comboDetail";
        private const string StorageInForm = "StorageInForm";
        private const string StorageOutForm = "StorageOutForm";
        private const string StoreForm = "StoreForm";
        private const string PcOrderForm = "PcOrderForm";


        /// <summary>
        /// Http上下文
        /// </summary>
        static HttpContext ContextHttp
        {
            get
            {
                return HttpContext.Current;
            }
        }
        static System.Web.SessionState.HttpSessionState Session
        {
            get
            {
                return ContextHttp.Session;
            }
        }

        static HttpResponse Response
        {
            get
            {
                return ContextHttp.Response;
            }
        }

        static HttpRequest Request
        {
            get
            {
                return ContextHttp.Request;
            }
        }
        public static BD_UserInfo UserInfo
        {
            get
            {
                if (Session["userinfo"]==null)
                {
                    Response.Redirect("/Login.aspx");
                }
                return Session["userinfo"] as BD_UserInfo;
            }
        }

       

        
       


   

       

       

       




        public static int Page
        {
            get
            {
                if (Request.Form[page] != null)
                {
                    return Commons.String2Int32(Request.Form[page].ToString());
                }
                else
                {
                    return 1;
                }
            }
        }

        public static int Rows
        {
            get
            {
                if (Request.Form[rows] != null)
                {
                    return Commons.String2Int32(Request.Form[rows].ToString());
                }
                else
                {
                    return 1;
                }
            }
        }
        public static string Sort
        {
            get
            {
                if (Request.Form[sort] != null)
                {
                    return Request.Form[sort].ToString();
                }
                else
                {
                    return null;
                }
            }
        }
        public static bool Order
        {
            get
            {
                if (Request.Form[order] != null)
                {
                    if (string.Equals(Request.Form[order].ToString(), "asc"))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return true;
                }
            }
        }

        public static bool OrderDesc
        {
            get
            {
                if (Request.Form[order] != null)
                {
                    if (string.Equals(Request.Form[order].ToString(), "asc"))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }
        }

    }
}